package com.whty.cms.filewps.upload.dto;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;


@Table(name="t_attach_file")
public class AttachFile {
	@Id
	@Column(name="fid")
    private Long fid;
	private String fidstr;
    private String fileName;
    private String fileMd5;
    private Long fileLength;
    private String fileSize;
    private String fileExt;
    private String userId;
    private Date postedTime;
    private String status;
    private String filePath;
    private String sourceType;
    private String yunType;
    private String platformCode;
    private String applyType;
    private String transformId;
    private String thumbnailId;
    private String uploadId;
    private String needTransform;
    private String userName;
	private String avatarUrl;
	private String permission;
	private String resId;
	private String from;
    public AttachFile() {
    	
    }
    
    public AttachFile(Long fid, String fileName, String fileMd5, Long fileLength, String fileSize, String fileExt, String userId, String applyType,
                      Date postedTime, String status, String filePath, String sourceType, String yunType, String platformCode, String transformId, String thumbnailId,
                      String uploadId, String needTransform) {
        this.fid = fid;
        this.fileName = fileName;
        this.fileMd5 = fileMd5;
        this.fileLength = fileLength;
        this.fileSize = fileSize;
        this.fileExt = fileExt;
        this.userId = userId;
        this.postedTime = postedTime;
        this.status = status;
        this.filePath = filePath;
        this.sourceType = sourceType;
        this.yunType = yunType;
        this.platformCode = platformCode;
        this.applyType = applyType;
        this.transformId = transformId;
        this.thumbnailId = thumbnailId;
        this.uploadId = uploadId;
        this.needTransform = needTransform;
    }

	public Long getFid() {
		return fid;
	}

	public void setFid(Long fid) {
		this.fid = fid;
	}

	public String getFidstr() {
		return fidstr;
	}

	public void setFidstr(String fidstr) {
		this.fidstr = fidstr;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	
	public String getFileMd5() {
		return fileMd5;
	}

	public void setFileMd5(String fileMd5) {
		this.fileMd5 = fileMd5;
	}

	public Long getFileLength() {
		return fileLength;
	}

	public void setFileLength(Long fileLength) {
		this.fileLength = fileLength;
	}

	public String getFileSize() {
		Long fileLength = getFileLength();
		if(null!=fileLength){
			if (fileLength < 1024) {
				return String.valueOf(fileLength) + "B";
			} else {
				fileLength = fileLength / 1024;
			}
			if (fileLength < 1024) {
				return String.valueOf(fileLength) + "KB";
			} else {
				fileLength = fileLength / 1024;
			}
			if (fileLength < 1024) {
				fileLength = fileLength * 100;
				return String.valueOf((fileLength / 100)) + "."
						+ String.valueOf((fileLength % 100)) + "MB";
			} else {
				fileLength = fileLength * 100 / 1024;
				return String.valueOf((fileLength / 100)) + "."
						+ String.valueOf((fileLength % 100)) + "GB";
			}
		}else{
			return "0B";
		}

	}

	public void setFileSize(String fileSize) {
		this.fileSize = fileSize;
	}

	public String getFileExt() {
		return fileExt;
	}

	public void setFileExt(String fileExt) {
		this.fileExt = fileExt;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public Date getPostedTime() {
		return postedTime;
	}

	public void setPostedTime(Date postedTime) {
		this.postedTime = postedTime;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}

	public String getSourceType() {
		return sourceType;
	}

	public void setSourceType(String sourceType) {
		this.sourceType = sourceType;
	}

	public String getYunType() {
		return yunType;
	}

	public void setYunType(String yunType) {
		this.yunType = yunType;
	}

	public String getPlatformCode() {
		return platformCode;
	}

	public void setPlatformCode(String platformCode) {
		this.platformCode = platformCode;
	}
	
	public String getApplyType() {
		return applyType;
	}

	public void setApplyType(String applyType) {
		this.applyType = applyType;
	}

	public String getTransformId() {
		return transformId;
	}

	public void setTransformId(String transformId) {
		this.transformId = transformId;
	}
	
	public String getThumbnailId() {
		return thumbnailId;
	}

	public void setThumbnailId(String thumbnailId) {
		this.thumbnailId = thumbnailId;
	}

	public String getUploadId() {
		return uploadId;
	}

	public void setUploadId(String uploadId) {
		this.uploadId = uploadId;
	}

	public String getNeedTransform() {
		return needTransform;
	}

	public void setNeedTransform(String needTransform) {
		this.needTransform = needTransform;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getAvatarUrl() {
		return avatarUrl;
	}

	public void setAvatarUrl(String avatarUrl) {
		this.avatarUrl = avatarUrl;
	}

	public String getPermission() {
		return permission;
	}

	public void setPermission(String permission) {
		this.permission = permission;
	}

	public String getResId() {
		return resId;
	}

	public void setResId(String resId) {
		this.resId = resId;
	}

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}
}